//
//  ZWHtmlController.m
//  NewProject
//
//  Created by tongtong on 2018/5/21.
//  Copyright © 2018年 chenIos. All rights reserved.
//

#import "ZWHtmlController.h"
#import <WebKit/WebKit.h>
@interface ZWHtmlController ()<WKUIDelegate,WKNavigationDelegate,WKScriptMessageHandler>
@property (nonatomic,strong) WKWebView *webView;

@end

@implementation ZWHtmlController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.titleStr;

    [self setupWebView];

}
#pragma mark -- 初始化webView
- (void)setupWebView{
    WKWebViewConfiguration *config = [WKWebViewConfiguration new];
    
    //偏好设置
    config.preferences = [WKPreferences new];
    config.preferences.minimumFontSize = 10;
    config.preferences.javaScriptEnabled = true;
    config.processPool = [WKProcessPool new];
    //通过js与webView内容交互
    config.userContentController = [WKUserContentController new];
    if (iPhoneX) {
        self.webView =  [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H-108) configuration:config];
        
    }else{
        self.webView =  [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H -Scare_Width(64)) configuration:config];
        
    }
    
    self.webView.backgroundColor = COLOR_WHITE;
    [self.view addSubview:_webView];
    
    _webView.navigationDelegate = self;
    _webView.UIDelegate = self;
    [self.webView loadHTMLString:self.urlStr baseURL:nil];
}
#pragma mark -- 获取数据 从h5
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message{
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
}
@end
